﻿<!--File Info Header
________________________________________________________________________________________

  Copyright (C) 2011 Jason Zhang, eagleboost@msn.com

  * THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, 
  * EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED 
  * WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.

________________________________________________________________________________________*/
-->

<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:EagleBoost.Wpf.Presentation.Controls.ColorPicker"
    xmlns:controls="clr-namespace:EagleBoost.Wpf.Presentation.Controls">

  <BooleanToVisibilityConverter x:Key="b2vConverter"/>
  
  <Style TargetType="{x:Type RadioButton}" x:Key="ColorButton">
    <Style.Setters>
      <Setter Property="Focusable" Value="False"/>
      <Setter Property="BorderThickness" Value="1"/>
      <Setter Property="Template">
        <Setter.Value>
          <ControlTemplate TargetType="{x:Type RadioButton}">
            <Grid SnapsToDevicePixels="True">
              <Border Margin="0" BorderThickness="{TemplateBinding BorderThickness}" x:Name="border">
                <Border Margin="2" BorderBrush="Gray" BorderThickness="1">
                  <Rectangle Fill="{TemplateBinding Background}"/>
                </Border>
              </Border>
              <Border Name="BackgroundOverlay" Opacity="0" BorderThickness="1" BorderBrush="Gray" CornerRadius="2"/>
              <ContentPresenter VerticalAlignment="Center" HorizontalAlignment="Center"/>
            </Grid>
            <ControlTemplate.Resources>
              <Storyboard x:Key="HoverOn">
                <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="BackgroundOverlay" Storyboard.TargetProperty="(UIElement.Opacity)">
                  <SplineDoubleKeyFrame KeyTime="00:00:00.1000000" Value="1" />
                </DoubleAnimationUsingKeyFrames>
              </Storyboard>
              <Storyboard x:Key="HoverOff">
                <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="BackgroundOverlay" Storyboard.TargetProperty="(UIElement.Opacity)">
                  <SplineDoubleKeyFrame KeyTime="00:00:00.2000000" Value="0" />
                </DoubleAnimationUsingKeyFrames>
              </Storyboard>
            </ControlTemplate.Resources>
            <ControlTemplate.Triggers>
              <Trigger Property="IsMouseOver" Value="true">
                <Trigger.ExitActions>
                  <BeginStoryboard x:Name="HoverOff_BeginStoryboard" Storyboard="{StaticResource HoverOff}"/>
                </Trigger.ExitActions>
                <Trigger.EnterActions>
                  <BeginStoryboard Storyboard="{StaticResource HoverOn}"/>
                </Trigger.EnterActions>
              </Trigger>
              <Trigger Property="IsChecked" Value="true">
                <Setter TargetName="border" Property="BorderBrush" Value="Gray"/>
                <Setter TargetName="border" Property="CornerRadius"  Value="2"/>
              </Trigger>
            </ControlTemplate.Triggers>
          </ControlTemplate>
        </Setter.Value>
      </Setter>
    </Style.Setters>
  </Style>

  <Style TargetType="{x:Type local:ColorPickerControl}" x:Key="ColorPickerControl">
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type local:ColorPickerControl}">
          <Grid>
            <Grid.ColumnDefinitions>
              <ColumnDefinition Width="50*"/>
              <ColumnDefinition Width="50*"/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
              <RowDefinition Height="15*"></RowDefinition>
              <RowDefinition Height="10*"></RowDefinition>
              <RowDefinition Height="Auto"></RowDefinition>
              <RowDefinition Height="50*"></RowDefinition>
              <RowDefinition Height="Auto"></RowDefinition>
              <RowDefinition Height="10*"></RowDefinition>
              <RowDefinition Height="Auto"></RowDefinition>
              <RowDefinition Height="Auto"></RowDefinition>
            </Grid.RowDefinitions>
            <controls:AutoLayoutGrid Grid.Row="0" Grid.ColumnSpan="2" x:Name="PART_NoColorGrid"/>
            <controls:AutoLayoutGrid Grid.Row="1" Grid.ColumnSpan="2" x:Name="PART_ThemeBaseColorsGrid"/>
            <Border Grid.Row="2" Grid.ColumnSpan="2" Height="1" Margin="3,6,3,6" BorderThickness="1" BorderBrush="LightGray"/>
            <controls:AutoLayoutGrid Grid.Row="3" Grid.ColumnSpan="2" x:Name="PART_ThemeColorsGrid" Orientation="Horizontal"/>
            <Border Grid.Row="4" Grid.ColumnSpan="2" Height="1" Margin="3,6,3,6" BorderThickness="1" BorderBrush="LightGray"/>
            <controls:AutoLayoutGrid Grid.ColumnSpan="2" Grid.Row="5" x:Name="PART_BasicColorsGrid"/>
            <Border Grid.Row="6" Grid.ColumnSpan="2" Height="1" Margin="3,6,3,6" BorderThickness="1" BorderBrush="LightGray"
                    Visibility="{Binding IsAdvancedOptionVisible, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource b2vConverter}}"/>
            <Button Grid.Row="7" Grid.Column="0" x:Name="PART_MoreColorsButton" Content="_More Colors..." Margin="2,0,2,0" Width="Auto"
                    Visibility="{Binding IsAdvancedOptionVisible, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource b2vConverter}}"/>
          </Grid>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>
</ResourceDictionary>
